<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // 传过来的id
  const list = [
    { id: 1, text: '无' },
    { id: 2, text: '无权限' },
    { id: 3, text: '无权限' },
    { id: 4, text: '管理' },
    { id: 5, text: '无' },
  ]
  const arr = [
    { id: 1, text: '管理' },
    // { id: 2, text: '无' },
    // { id: 2, text: '无权限' },
    // { id: 2, text: '无' },
    // { id: 2, text: '无权限' },
    // { id: 101, text: '管理' },
    // { id: 3, text: '测试数据' },
    { id: 1, text: '管理' },
    // { id: 1, text: '测试数据' },
  ]

  const text = '无'
  let idArr = list.filter(o => o.text === text).map(o => o.id)

  // 拿到数据中的id，去重后存起来  ----->  [1,5]
  idArr = [...new Set(idArr)]

  console.log(idArr, 123);
  // 遍历id数组idArr
  allList: for (let i = 0; i < idArr.length; i++) {
    let forArr = arr.filter(o => o.id === idArr[i])

    for (let j = 0; j < forArr.length; j++) {
      const { id } = forArr[j];
      if (forArr.length === 0) {
        alert(`id为：${id}，text为 ${text} 的数据有且只有 0 条`)
        break allList
      } else if (forArr.length > 1) {
        alert(`id为：${id}，text为 ${text} 的数据有 ${forArr.length} 条`)
        break allList
      } else {
        console.log(`需求为 ${text} ,id 为 ${id} 在第二个数组中有且只有一条`)
      }
    }
  }
</script>

</html>